<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="./jquery-3.5.1.js"></script>
    <style>
      div {
        width: 400px;
        height: 200px;
        border: 1px solid #000;
        margin: 100px auto;
      }
      #btn {
        background-color: #fff;
        border: 1px solid skyblue;
        border-radius: 4px;
        outline-style: none;
      }
    </style>
  </head>
  <body>
    <div>
      <h2>开心一笑<button id="btn">换一个</button></h2>
      <p id="content">加载中...</p>
    </div>
  </body>
  <script>
    $(function () {
      function getData() {
        $.ajax({
          type: "get",
          url: "https://autumnfish.cn/api/joke",
          success: function (backData) {
            // console.log(backData);
            $("#content").text(backData);
          },
        });
      }
      getData();
      $("#btn").on("click", function () {
        $("#content").text("加载中...");
        getData();
      });
    });
  </script>
</html>
